public class SubtractExpression extends AbstractExpression{
    public SubtractExpression(double num1, double num2) {
        super(num1, num2);
    }

    // 实现减法计算
    @Override
    public void calculate() {
        this.result = num1 - num2;
    }

    // 实现减法算式字符串
    @Override
    public String getExpression() {
        if (!isValid) {
            return "无效减法算式";
        }
        return String.format("%.1f - %.1f = %.1f", num1, num2, result);
    }

}
